package com.zeratul.common.event.core.handler.local;

import com.zeratul.common.event.base.BaseSubscribeHandler;
import com.zeratul.common.event.domain.ZtEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;

/**
 * Spring事件监听处理
 */
@Slf4j
public class SpringEventSubscribeHandler implements ApplicationListener<ZtApplicationEvent>, BaseSubscribeHandler {

    @Override
    public void onApplicationEvent(ZtApplicationEvent event) {
        //获取事件中的内容
        if (event.getZtEvent() instanceof ZtEvent<?> ztEvent) {
            //调用事件处理方法
            doHandler(ztEvent);
        }
    }
}
